package com.slipper.system.version.controller;

import com.slipper.system.version.properties.VersionProperties;
import com.slipper.util.Tool;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.slipper.util.ResultUtil;

import java.util.HashMap;
import java.util.Map;

/**
 * 版本信息表
 */
@RestController
@RequestMapping("/system/version")
public class VersionController {
    @Resource
    private VersionProperties versionProperties;

    @PostMapping(value = "/queryBy")
    public String queryBy() {
        Map<String, Object> data = new HashMap<>();
        data.put("version", versionProperties.getVersion());
        data.put("branch", versionProperties.getBranch());
        data.put("branchVersion", versionProperties.getBranchVersion());
        String branchTime = versionProperties.getBranchTime();
        data.put("publishDate", Tool.isNotBlank(branchTime) ? branchTime.split("T")[0] : "");
        return ResultUtil.successResult(data);
    }
}
